package com.jamie.controller;

import com.jamie.domain.Merchant;
import com.jamie.domain.Product;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 594781919
 * @date 2019/7/11
 */
@Controller
public class ProductController {

    @GetMapping("/product/list")
    public String listProducts(Model model) {
        List<Product> products = new ArrayList<>();
        products.add(new Product(1001, "手机", 3999.00));
        products.add(new Product(1002, "电脑", 8999.00));
        products.add(new Product(1003, "鼠标", 59.99));
        products.add(new Product(1004, "键盘", 499.99));
        model.addAttribute("products", products);

        model.addAttribute("merchant", new Merchant("布特", 33));

        return "product/list.html";
    }
}
